package com.ruoyi.cms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cms.domain.CmsSiteLy;
import com.ruoyi.cms.service.ICmsSiteLyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * CMS建站系统-用户留言Controller
 * 
 * @author ruoyi
 * @date 2022-09-15
 */
@RestController
@RequestMapping("/cms/ly")
public class CmsSiteLyController extends BaseController
{
    @Autowired
    private ICmsSiteLyService cmsSiteLyService;

    /**
     * 查询CMS建站系统-用户留言列表
     */
    @PreAuthorize("@ss.hasPermi('cms:ly:list')")
    @GetMapping("/list")
    public TableDataInfo list(CmsSiteLy cmsSiteLy)
    {
        startPage();
        List<CmsSiteLy> list = cmsSiteLyService.selectCmsSiteLyList(cmsSiteLy);
        return getDataTable(list);
    }

    /**
     * 导出CMS建站系统-用户留言列表
     */
    @PreAuthorize("@ss.hasPermi('cms:ly:export')")
    @Log(title = "CMS建站系统-用户留言", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmsSiteLy cmsSiteLy)
    {
        List<CmsSiteLy> list = cmsSiteLyService.selectCmsSiteLyList(cmsSiteLy);
        ExcelUtil<CmsSiteLy> util = new ExcelUtil<CmsSiteLy>(CmsSiteLy.class);
        util.exportExcel(response, list, "CMS建站系统-用户留言数据");
    }

    /**
     * 获取CMS建站系统-用户留言详细信息
     */
    @PreAuthorize("@ss.hasPermi('cms:ly:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(cmsSiteLyService.selectCmsSiteLyById(id));
    }

    /**
     * 新增CMS建站系统-用户留言
     */
    @PreAuthorize("@ss.hasPermi('cms:ly:add')")
    @Log(title = "CMS建站系统-用户留言", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmsSiteLy cmsSiteLy)
    {
        return toAjax(cmsSiteLyService.insertCmsSiteLy(cmsSiteLy));
    }

    /**
     * 修改CMS建站系统-用户留言
     */
    @PreAuthorize("@ss.hasPermi('cms:ly:edit')")
    @Log(title = "CMS建站系统-用户留言", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmsSiteLy cmsSiteLy)
    {
        return toAjax(cmsSiteLyService.updateCmsSiteLy(cmsSiteLy));
    }

    /**
     * 删除CMS建站系统-用户留言
     */
    @PreAuthorize("@ss.hasPermi('cms:ly:remove')")
    @Log(title = "CMS建站系统-用户留言", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cmsSiteLyService.deleteCmsSiteLyByIds(ids));
    }
}
